package main

import (
	_ "open_manjing/oss/routers"
	_ "github.com/go-sql-driver/mysql"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
)

// 数据库注册
func ormRegister() {
	user := beego.AppConfig.String("mysql.default.user")
	pass := beego.AppConfig.String("mysql.default.pass")
	host := beego.AppConfig.String("mysql.default.host")
	port := beego.AppConfig.String("mysql.default.port")
	db := beego.AppConfig.String("mysql.default.db")
	orm.RegisterDriver("mysql", orm.DRMySQL)
	//set default database
	orm.RegisterDataBase("default", "mysql", user+":"+pass+"@tcp("+host+":"+port+")/"+db+"?charset=utf8")
	//create table
	orm.RunSyncdb("default", false, true)
	//sql debug
	orm.Debug = true
}

// main.
func main() {
	beego.SetStaticPath("/swagger", "swagger")
	ormRegister()
	beego.Run()
}
